/************************************************
* 文件描述: 联系我们页的类
* 待完善:
* 待优化:
* 修改日期：2020.11.04
* 修改内容：
*   创建  HZH
*************************************************/
#include "contact_page.h"
/************************************************
* 函数名称：ContactPage
* 功能描述：构造函数
* 输入参数：窗口各参数类
* 输出参数：无
* 修改日期：2020.11.04
* 修改内容：
*   创建  HZH
*
*************************************************/
const QString BTN_TO_LABEL_STYLE = "QPushButton{border:0px;border-radius:4px;background:transparent;}"
                                   "QPushButton:Hover{border:0px;border-radius:4px;background:transparent;}"
                                   "QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;}";
ContactPage::ContactPage(QWidget *parent):
    QWidget(parent)
{
    this->setWindowTitle("contact_page");
    initContactPageUI();
}

/************************************************
* 函数名称：initContactPageUI
* 功能描述：界面ui初始化
* 输入参数：无
* 输出参数：无
* 修改日期：2020.11.04
* 修改内容：
*   创建  HZH
*
*************************************************/
void ContactPage::initContactPageUI()
{
    m_body = new QWidget(this);
    m_body->setFixedSize(700,268);
    m_body->setObjectName("body");
    m_body->setStyleSheet("QWidget#body{background:palette(Window);border:0px;border-radius:8px;}");

    m_pContactUs = new QLabel(this);
    m_pContactUs->adjustSize();
    m_pContactUs->setText(tr("Contact Us"));
//    m_pContactUs->setText("联系我们");
    m_pContactUs->setAlignment(Qt::AlignLeft);
    m_pContactUs->setAlignment(Qt::AlignVCenter);

    m_pKylinTeam_1 = new KToolButton(this);
    m_pKylinTeam_1->setIcon(QIcon::fromTheme("stock-people-symbolic"));
    m_pKylinTeam_1->setEnabled(false);
    m_pKylinTeam_1->installEventFilter(this);

    m_pKylinTeam_2 = new QLabel(this);
    m_pKylinTeam_2->adjustSize();//->setFixedSize(98,20);
    m_pKylinTeam_2->setText(tr("Support Team"));
//    m_pKylinTeam_2->setText("服务与支持团队");
    m_pKylinTeam_2->setAlignment(Qt::AlignLeft);
    m_pKylinTeam_2->setAlignment(Qt::AlignVCenter);

    m_pKylinTeam_3 = new QLabel(this);
    m_pKylinTeam_3->adjustSize();//setFixedSize(180,20);
    m_pKylinTeam_3->setText("KylinOS Support Team");
    m_pKylinTeam_3->setAlignment(Qt::AlignLeft);
    m_pKylinTeam_3->setAlignment(Qt::AlignVCenter);

    m_pTel_1 = new KToolButton(this);
    m_pTel_1->setIcon(QIcon::fromTheme("call-stop-symbolic"));
    m_pTel_1->setEnabled(false);

    m_pTel_2 = new QLabel(this);
    m_pTel_2->adjustSize();//setFixedSize(28,20);
//    m_pTel_2->setText("电话");
    m_pTel_2->setText(tr("Tel"));
    m_pTel_2->setAlignment(Qt::AlignLeft);
    m_pTel_2->setAlignment(Qt::AlignVCenter);

    m_pTel_3 = new QLabel(this);
    m_pTel_3->setFixedSize(148,20);
    m_pTel_3->setText("400-089-1870");
    m_pTel_3->setAlignment(Qt::AlignLeft);
    m_pTel_3->setAlignment(Qt::AlignVCenter);

    m_pMail_1 = new KToolButton(this);
    m_pMail_1->setIcon(QIcon::fromTheme("mail-read-symbolic"));
    m_pMail_1->setEnabled(true);

    m_pMail_2 = new QLabel(this);
    m_pMail_2->adjustSize();//setFixedSize(28,20);
    m_pMail_2->setText(tr("E-mail"));//"邮件");
    m_pMail_2->setAlignment(Qt::AlignLeft);
    m_pMail_2->setAlignment(Qt::AlignVCenter);

    m_pMail_3 = new QLabel(this);
    m_pMail_3->adjustSize();//setFixedSize(148,20);
    m_pMail_3->setText("support@kylinos.cn");
    m_pMail_3->setAlignment(Qt::AlignLeft);
    m_pMail_3->setAlignment(Qt::AlignVCenter);

    m_pQRCode_1 = new QLabel(this);
    m_pQRCode_1->setFixedSize(118,118);
    m_pQRCode_1->setStyleSheet("border-image:url(:/data/qcpic.png);border:0px;");

    m_pQRCode_2 = new QLabel(this);
    m_pQRCode_2->adjustSize();//setFixedSize(154,20);
    m_pQRCode_2->setText(tr("Kylin WeChat Official Account"));//"公众号麒麟软件技术服务");
    m_pQRCode_2->setAlignment(Qt::AlignLeft);
    m_pQRCode_2->setAlignment(Qt::AlignVCenter);

    QHBoxLayout *HContactLayout_1 = new QHBoxLayout();
    HContactLayout_1->setMargin(0);
    HContactLayout_1->setSpacing(0);
    HContactLayout_1->addSpacing(30);
    HContactLayout_1->addWidget(m_pContactUs);
    HContactLayout_1->addStretch();

    QHBoxLayout *HTeamLayout_1 = new QHBoxLayout();
    HTeamLayout_1->setMargin(0);
    HTeamLayout_1->setSpacing(0);
    HTeamLayout_1->addSpacing(0);
    HTeamLayout_1->addWidget(m_pKylinTeam_1);
    HTeamLayout_1->addSpacing(4);
    HTeamLayout_1->addWidget(m_pKylinTeam_2);
    HTeamLayout_1->addSpacing(26);
    HTeamLayout_1->addStretch();

    QHBoxLayout *HTeleLayout_1 = new QHBoxLayout();
    HTeleLayout_1->setMargin(0);
    HTeleLayout_1->setSpacing(0);
    HTeleLayout_1->addSpacing(0);
    HTeleLayout_1->addWidget(m_pTel_1);
    HTeleLayout_1->addSpacing(4);
    HTeleLayout_1->addWidget(m_pTel_2);
    HTeleLayout_1->addSpacing(48);
    HTeleLayout_1->addStretch();

    QHBoxLayout *HMailLayout_1 = new QHBoxLayout();
    HMailLayout_1->setMargin(0);
    HMailLayout_1->setSpacing(0);
    HMailLayout_1->addSpacing(0);
    HMailLayout_1->addWidget(m_pMail_1,1);
    HMailLayout_1->addSpacing(4);
    HMailLayout_1->addWidget(m_pMail_2,1);
    HMailLayout_1->addSpacing(48);
    HMailLayout_1->addStretch();

    QVBoxLayout *VBoxLayout_1 = new QVBoxLayout();
    VBoxLayout_1->setMargin(0);
    VBoxLayout_1->setSpacing(0);
    VBoxLayout_1->addSpacing(50);
    VBoxLayout_1->addLayout(HTeamLayout_1);
    VBoxLayout_1->addSpacing(4);
    VBoxLayout_1->addWidget(m_pKylinTeam_3,1);
    VBoxLayout_1->addSpacing(20);
    VBoxLayout_1->addLayout(HTeleLayout_1);
    VBoxLayout_1->addSpacing(2);
    VBoxLayout_1->addWidget(m_pTel_3,1);
    VBoxLayout_1->addSpacing(20);
    VBoxLayout_1->addLayout(HMailLayout_1);
    VBoxLayout_1->addSpacing(2);
    VBoxLayout_1->addWidget(m_pMail_3);
    VBoxLayout_1->addSpacing(50);
    VBoxLayout_1->addStretch();

    QHBoxLayout *HQRLayout_1 = new QHBoxLayout();
    HQRLayout_1->setMargin(0);
    HQRLayout_1->setSpacing(0);
    HQRLayout_1->addStretch();
    HQRLayout_1->addSpacing(8);
    HQRLayout_1->addWidget(m_pQRCode_1);
    HQRLayout_1->addStretch();

    QHBoxLayout *HQRLayout_2 = new QHBoxLayout();
    HQRLayout_2->setMargin(0);
    HQRLayout_2->setSpacing(0);
    HQRLayout_2->addWidget(m_pQRCode_2);
    HQRLayout_2->addStretch();

    QVBoxLayout *VBoxLayout_2 = new QVBoxLayout();
    VBoxLayout_2->setMargin(0);
    VBoxLayout_2->setSpacing(0);
    VBoxLayout_2->addSpacing(60);
    VBoxLayout_2->addLayout(HQRLayout_1);
    VBoxLayout_2->addSpacing(10);
    VBoxLayout_2->addLayout(HQRLayout_2);
    VBoxLayout_2->addSpacing(60);
    VBoxLayout_2->addStretch();

    QHBoxLayout *HBoxLayout = new QHBoxLayout();
    HBoxLayout->setMargin(0);
    HBoxLayout->setSpacing(0);
    HBoxLayout->addSpacing(70);
    HBoxLayout->addLayout(VBoxLayout_1);
    HBoxLayout->addStretch(280);
    HBoxLayout->addLayout(VBoxLayout_2);
    HBoxLayout->addSpacing(70);

    m_body->setLayout(HBoxLayout);

    QHBoxLayout *HAllLayout = new QHBoxLayout();
    HAllLayout->setMargin(0);
    HAllLayout->setSpacing(0);
    HAllLayout->addSpacing(30);
    HAllLayout->addWidget(m_body);
    HAllLayout->addStretch();

    QVBoxLayout *VAllLayout = new QVBoxLayout(this);
    VAllLayout->setMargin(0);
    VAllLayout->setSpacing(0);
    VAllLayout->addSpacing(0);
    VAllLayout->addLayout(HContactLayout_1);
    VAllLayout->addSpacing(16);
    VAllLayout->addLayout(HAllLayout);
    VAllLayout->addStretch();

    this->setLayout(VAllLayout);
}

void ContactPage::changeFont(QFont curFont)
{
    double smallFontSize = (static_cast<double>(curFont.pointSizeF())/14)*12;
    QFont smallFont;
    smallFont.setPointSizeF(smallFontSize);

    m_pContactUs->setFont(curFont);
    m_pQRCode_2->setFont(curFont);
    m_pMail_3->setFont(curFont);
    m_pMail_2->setFont(curFont);
    m_pTel_3->setFont(curFont);
    m_pTel_2->setFont(curFont);
    m_pKylinTeam_3->setFont(curFont);
    m_pKylinTeam_2->setFont(curFont);
}
